<template>
  <div>
    <van-row>
      <van-col span="12">
        <van-field label='姓名' v-model='form.name'/>
        <van-field label='金额' v-model='form.money'/>
        <van-field label='机构名称' v-model='form.company'/>
        客户经理
        <select v-model='form.manager_id'>
          <option :value="i.id" v-for='i in managelist' :key="i.id">{{i.name}}</option>
        </select>
        注册来源
        <select v-model='form.refromid'>
          <option :value="i.id" v-for='i in resourcelist' :key="i.id">{{i.name}}</option>
        </select>

        <van-button @click='submit'>提交</van-button>
      </van-col>
      <van-col span="12">
        <ul>
          <li v-for='i in list' :key="i.id">{{i.name}}
            <van-button @click='audit(i.id)'>审核</van-button>
          </li>
        </ul>

        <!-- <van-dialog v-model:show="show" title="标题" show-cancel-button>
                <img src="https://img01.yzcdn.cn/vant/apple-3.jpg" />
              </van-dialog> -->

        <van-dialog v-model:show="show" title="标题" show-cancel-button>

          <van-field :label='描述信息' v-model='descipt'/>
          <van-radio-group v-model="is_agree">
            <van-radio name="2">通过</van-radio>
            <van-radio name="3">未通过</van-radio>
          </van-radio-group>
          <van-button @click='submit1'>提交</van-button>
        </van-dialog>
      </van-col>
    </van-row>

  </div>
</template>
<script>
import myaxios from "../../../https/myaxios";
import axios from 'axios';

export default {
  name:'mywebsocket',
  data(){
    return{
      form:{
        name:'',
        money:'',
        company:'',
        manager_id:'',
        refromid:''
      },
      managelist:[],
      resourcelist:[],
      list:[],
      show:false,
      descipt:'',
      is_agree:2,
      id:0,
    }
  },
  methods: {
    getlist(){
      axios.get('http://localhost:8000/showuseraudit').then(res=>{
        this.list = res.data.list
      })
    },
    audit(id){
      this.id=id
      this.show=true
    },
    submit1(){
      axios.post('http://localhost:8000/audit',{'id':this.id,'descipt':this.descipt,'is_agree':this.is_agree,"userid":localStorage.getItem("userid")}).then(res=>{
          alert(res)
      })
    },
    getmanagelist(){
      myaxios('managelist','get').then(res=>{
        this.managelist=res.list
        this.getresourcelist()
      })
    },
    getresourcelist(){
      myaxios('resourcelist','get').then(res=>{
        this.resourcelist=res.list
      })
    },
    submit(){
      let data = new FormData()
      data.append("name",this.form.name)
      data.append("money",this.form.money)
      data.append("company",this.form.company)
      data.append("manager_id",this.form.manager_id)
      data.append("refromid",this.form.refromid)
      myaxios('customer_reg','post',data).then(res=>{
        console.log(res)
      })
    }
  },
  mounted() {
    this.getmanagelist()
    this.getlist()
    // this.getresourcelist()
  },
}
</script>
<style scoped>

</style>